WT_DECLARE_WT_MEMBER(10,JavaScriptConstructor,"WPaintedWidget",function(J,p){jQuery.data(p,"obj",this);var q=this;this.imagePreloader=null;this.images=[];this.canvas=document.getElementById("c"+p.id);this.repaint=function(){};this.widget=p;this.cancelPreloader=function(){var r=q.imagePreloader;r&&r.cancel();q.imagePreloader=null}});
WT_DECLARE_WT_MEMBER(11,JavaScriptObject,"gfxUtils",function(){function J(){var g=this;this.path_crisp=function(a){return a.map(function(b){return[Math.floor(b[0])+0.5,Math.floor(b[1])+0.5,b[2]]})};this.transform_mult=function(a,b){if(b.length===2){var c=b[0],e=b[1];return[a[p]*c+a[q]*e+a[v],a[r]*c+a[s]*e+a[w]]}if(b.length===3){if(b[2]===B||b[2]===C)return b.slice(0);c=b[0];e=b[1];return[a[p]*c+a[q]*e+a[v],a[r]*c+a[s]*e+a[w],b[2]]}if(b.length===4){var f,h,d,l;h=g.transform_mult(a,[b[0],b[1]]);c=h[0];
f=h[0];e=h[1];h=h[1];for(d=0;d<3;++d){l=g.transform_mult(a,d==0?[g.rect_left(b),g.rect_bottom(b)]:d==1?[g.rect_right(b),g.rect_top(b)]:[g.rect_right(b),g.rect_bottom(b)]);c=Math.min(c,l[0]);f=Math.max(f,l[0]);e=Math.min(e,l[1]);h=Math.max(h,l[1])}return[c,e,f-c,h-e]}if(b.length===6)return[a[p]*b[p]+a[q]*b[r],a[p]*b[q]+a[q]*b[s],a[r]*b[p]+a[s]*b[r],a[r]*b[q]+a[s]*b[s],a[p]*b[v]+a[q]*b[w]+a[v],a[r]*b[v]+a[s]*b[w]+a[w]];return[]};this.transform_apply=function(a,b){var c=g.transform_mult;return b.map(function(e){return c(a,
e)})};this.transform_det=function(a){return a[p]*a[s]-a[q]*a[r]};this.transform_adjoint=function(a){var b=a[p],c=a[r],e=a[q],f=a[s],h=a[v];a=a[w];return[f,-c,-e,b,a*e-h*f,-(a*b-h*c)]};this.transform_inverted=function(a){var b=g.transform_det(a);if(b!=0){a=g.transform_adjoint(a);return[a[p]/b,a[r]/b,a[q]/b,a[s]/b,a[v]/b,a[w]/b]}else{console.log("inverted(): oops, determinant == 0");return a}};this.transform_assign=function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5]};this.transform_equal=
function(a,b){return a[0]==b[0]&&a[1]==b[1]&&a[2]==b[2]&&a[3]==b[3]&&a[4]==b[4]&&a[5]==b[5]};this.css_text=function(a){return"rgba("+a[0]+","+a[1]+","+a[2]+","+a[3]+")"};this.arcPosition=function(a,b,c,e,f){f=-f/180*Math.PI;return[a+c*Math.cos(f),b+e*Math.sin(f)]};this.pnpoly=function(a,b){var c=false,e=0,f=0,h=a[0];a=a[1];var d,l,j;for(d=0;d<b.length;++d){l=e;j=f;if(b[d][2]===K){j=g.arcPosition(b[d][0],b[d][1],b[d+1][0],b[d+1][1],b[d+2][0]);l=j[0];j=j[1]}else if(b[d][2]===C){j=g.arcPosition(b[d-
2][0],b[d-2][1],b[d-1][0],b[d-1][1],b[d][0]+b[d][1]);l=j[0];j=j[1]}else if(b[d][2]!==B){l=b[d][0];j=b[d][1]}if(b[d][2]!==y)if(f>a!==j>a&&h<(l-e)*(a-f)/(j-f)+e)c=!c;e=l;f=j}return c};this.drawRect=function(a,b,c,e){b=g.rect_normalized(b);var f=g.rect_top(b),h=g.rect_bottom(b),d=g.rect_left(b);b=g.rect_right(b);path=[[d,f,y],[b,f,x],[b,h,x],[d,h,x],[d,f,x]];g.drawPath(a,path,c,e,false)};this.drawPath=function(a,b,c,e,f){function h(k){return k[0]}function d(k){return k[1]}function l(k){return k[2]}var j=
0,n=[],m=[],o=[];a.beginPath();b.length>0&&l(b[0])!==y&&a.moveTo(0,0);for(j=0;j<b.length;j++){var i=b[j];switch(l(i)){case y:a.moveTo(h(i),d(i));break;case x:a.lineTo(h(i),d(i));break;case P:n.push(h(i),d(i));break;case Q:n.push(h(i),d(i));break;case D:n.push(h(i),d(i));a.bezierCurveTo.apply(a,n);n=[];break;case K:m.push(h(i),d(i));break;case B:m.push(h(i));break;case C:m.push(h(i)*Math.PI/180,d(i)*Math.PI/180,d(i)>0);a.arc.apply(a,m);m=[];break;case S:o.push(h(i));break;case E:o.push(h(i),d(i));
a.quadraticCurveTo.apply(a,o);o=[];break}}c&&a.fill();e&&a.stroke();f&&a.clip()};this.drawStencilAlongPath=function(a,b,c,e,f,h){function d(o){return o[0]}function l(o){return o[1]}function j(o){return o[2]}var n=0;for(n=0;n<c.length;n++){var m=c[n];if(!(h&&a.wtClipPath&&!g.pnpoly(m,g.transform_apply(a.wtClipPathTransform,a.wtClipPath))))if(j(m)==y||j(m)==x||j(m)==E||j(m)==D){m=g.transform_apply([1,0,0,1,d(m),l(m)],b);g.drawPath(a,m,e,f,false)}}};this.drawText=function(a,b,c,e,f){if(!(f&&a.wtClipPath&&
!g.pnpoly(f,g.transform_apply(a.wtClipPathTransform,a.wtClipPath)))){var h=c&F;var d=f=null;switch(c&T){case M:a.textAlign="left";f=g.rect_left(b);break;case N:a.textAlign="right";f=g.rect_right(b);break;case O:a.textAlign="center";f=g.rect_center(b).x;break}switch(h){case G:a.textBaseline="top";d=g.rect_top(b);break;case H:a.textBaseline="bottom";d=g.rect_bottom(b);break;case I:a.textBaseline="middle";d=g.rect_center(b).y;break}if(!(f==null||d==null)){b=a.fillStyle;a.fillStyle=a.strokeStyle;a.fillText(e,
f,d);a.fillStyle=b}}};this.calcYOffset=function(a,b,c,e){return e===I?-((b-1)*c/2)+a*c:e===G?a*c:e===H?-(b-1-a)*c:0};this.drawTextOnPath=function(a,b,c,e,f,h,d,l,j){function n(A){return A[0]}function m(A){return A[1]}function o(A){return A[2]}var i=0,k=0;e=g.transform_apply(e,f);for(i=0;i<f.length;i++){if(i>=b.length)break;k=f[i];var u=e[i],z=b[i].split("\n");if(o(k)==y||o(k)==x||o(k)==E||o(k)==D)if(h==0)for(k=0;k<z.length;k++){var t=g.calcYOffset(k,z.length,d,l&F);g.drawText(a,[c[0]+n(u),c[1]+m(u)+
t,c[2],c[3]],l,z[k],j?[n(u),m(u)]:null)}else{t=h*Math.PI/180;k=Math.cos(-t);t=-Math.sin(-t);var U=-t;a.save();a.transform(k,U,t,k,n(u),m(u));for(k=0;k<z.length;k++){t=g.calcYOffset(k,z.length,d,l&F);g.drawText(a,[c[0],c[1]+t,c[2],c[3]],l,z[k],j?[n(u),m(u)]:null)}a.restore()}}};this.setClipPath=function(a,b,c,e){if(e){a.setTransform.apply(a,c);g.drawPath(a,b,false,false,true);a.setTransform(1,0,0,1,0,0)}a.wtClipPath=b;a.wtClipPathTransform=c};this.removeClipPath=function(a){delete a.wtClipPath;delete a.wtClipPathTransform};
this.rect_top=function(a){return a[1]};this.rect_bottom=function(a){return a[1]+a[3]};this.rect_right=function(a){return a[0]+a[2]};this.rect_left=function(a){return a[0]};this.rect_topleft=function(a){return[a[0],a[1]]};this.rect_topright=function(a){return[a[0]+a[2],a[1]]};this.rect_bottomleft=function(a){return[a[0],a[1]+a[3]]};this.rect_bottomright=function(a){return[a[0]+a[2],a[1]+a[3]]};this.rect_center=function(a){return{x:(2*a[0]+a[2])/2,y:(2*a[1]+a[3])/2}};this.rect_normalized=function(a){var b,
c,e;if(a[2]>0){b=a[0];e=a[2]}else{b=a[0]+a[2];e=-a[2]}if(a[3]>0){c=a[1];a=a[3]}else{c=a[1]+a[3];a=-a[3]}return[b,c,e,a]}}var p=0,q=1,r=2,s=3,v=4,w=5,y=0,x=1,P=2,Q=3,D=4,S=5,E=6,K=7,B=8,C=9,M=1,N=2,O=4,G=128,I=512,H=1024,F=112|G|256|I|H|2048,T=M|N|O|8;return new J}());
